package com.tnl.web.service;

import com.biz.hunter.dao.HunterDAO;
import com.biz.hunter.db.entity.Hunter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import static com.biz.wechat.util.CookieUtil.logger;

@Service
public class HunterService {

    @Autowired
    private HunterDAO hunterDAO;

    @Autowired
    private SMSService smsService;

    @Transactional
    public void approve(int hunterId) {
        hunterDAO.approve(hunterId);
        //todo 给顾问创建账号并通知
        Hunter hunter = hunterDAO.getById(hunterId);
        if (hunter!= null) {
            String text = hunter.getName()+",恭喜您!您的账号已通过审核！";
            smsService.sendSMS(hunter.getPhone(),text);
            logger.info("HR ["+hunter.getPhone()+"] 认证短信发送成功！");
        }

    }
}
